﻿using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using CallCenter.Data;
using CallCenter.Data.BizUtilities;
using System.Configuration;
using System.Data;
using CallCenter.Security;
using CallCenter.Data.Models;
using CallCenter.Data.Misc;
namespace CallCenter.Web.Controllers
{
    public class ContactDetailController : BaseController
    {
        // GET: ContactDetail
        public ActionResult Index()
        {
            return View();
        }     
        public ActionResult AddContactDetails()
        {
            ContactDetailsVM cmpy = new ContactDetailsVM();
            return View(cmpy);
        }
        [HttpPost]
        public JsonResult GetContactDetails(ContactDetailsVM model, int id)
        {
            var scratchPads = this.Bridge.ContactDetailUtility.getAll(id);
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }


        [HttpPost]
        public JsonResult CreateContactDetails(ContactDetailsVM model)
        {
           

            var returnMessage = this.Bridge.ContactDetailUtility.InsertToContactDetails(model);
           
            return Json(returnMessage, JsonRequestBehavior.AllowGet);
         
        }

        [HttpPost]
        public JsonResult UpdateContactDetails(ContactDetailsVM model)
        {
           
            var returnMessage = this.Bridge.ContactDetailUtility.UpdateToContactDetails(model);
          
            return Json(returnMessage, JsonRequestBehavior.AllowGet);
        
        }


        [HttpPost]
        public JsonResult DeleteContactDetails(ContactDetailsVM model)
        {
           
            int id = model.id;
            this.Bridge.ContactDetailUtility.delete(id);
            var returnMessage = "Success";
            return Json(returnMessage, JsonRequestBehavior.AllowGet);

        }

        public JsonResult GetBranchOffices()
        {
            var scratchPads = this.Bridge.ContactDetailUtility.GetBranchOffices();
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetAllJobTitles()
        {
            var scratchPads = this.Bridge.JobTitleUtility.GetAll();
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }

        public JsonResult GetJobTitle()
        {
            var scratchPads = this.Bridge.ContactDetailUtility.GetAllJobTitles();
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }

        public JsonResult GetAllContactTypes()
        {
            var scratchPads = this.Bridge.CompanyUtility.GetCompanyType();
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }

        public JsonResult GetAllCompanies()
        {
            var scratchPads = this.Bridge.ContactDetailUtility.GetAllCompanies();
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }

    }
}